package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Daily;
import cn.wolfcode.trip.base.query.DailyQueryObject;
import cn.wolfcode.trip.base.service.IDailyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * 日报资源控制器
 */
@RestController
@RequestMapping("dailies")
public class DailyController {
    @Autowired
    private IDailyService dailyService;

    //查询单条数据,根据ID来查 内容
    @GetMapping("/{id}")
    public Daily getById(@PathVariable Long id){
        System.out.println(id);
        Daily daily = dailyService.get(id);
        return daily;
    }

    @GetMapping("list")
    public PageInfo list(DailyQueryObject qo){
        //按照创建时间倒序
        qo.setStateId(1);
        qo.setOrderBy("createTime desc");
        return dailyService.query(qo);
    }


}
